<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>微信支付</title>
    <link rel="stylesheet" href="../css/page-health-orderNotice.css" />
    <link rel="stylesheet" href="../plugins/elementui/index.css" />
    <script src="../plugins/jquery/dist/jquery.min.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../plugins/vue/vue.js"></script>
    <script src="../plugins/vue/axios-0.18.0.js"></script>
    <script src="../plugins/elementui/index.js"></script>
</head>
<script>
    let id = getUrlParam("orderid");
</script>

<body data-spy="scroll" data-target="#myNavbar" data-offset="150">
<div id="app" class="app">
    <!-- 页面头部 -->
    <div class="top-header">
        <span class="f-left"><i class="icon-back" onclick="history.go(-1)"></i></span>
        <span class="center">传智健康</span>
        <span class="f-right"><i class="icon-more"></i></span>
    </div>
    <div class="contentBox">
        <img style="margin: auto; width: 600px " src="/wxpay/pay.do">
        </div>
    </div>
</div>

</body>
<script>
    const taskId = setInterval(() => {
        axios.get("/order/findState.do?orderId="+id)
            .then((res) => {
                // let state = res.data.data;
                if (res.data.data=="已支付"){
                    //付款成功
                    clearInterval(taskId);
                    // 跳转到付款成功页
                    location.href = "/pages/paySuccess.html?orderId=" + id;
                }
            }).catch((e) => {
            console.log("支付状态查询失败，请刷新页面重试。");
            clearInterval(taskId);
        })
    }, 3000);
    // 同时设置一个定时任务，1分钟后，终止查询，认为付款失败
    setTimeout(() => {
        clearInterval(taskId);
        location.href = "/pages/paySuccess.html?orderId=" + id;//60000
    }, 20000)
</script>
</html>